Set unused bits in pixel to 1s in case they are used as alpha; copying
authorMatthias Clasen <maclas@gmx.de>
Mon, 23 Aug 2004 05:19:52 +0000 (05:19 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 23 Aug 2004 05:19:52 +0000 (05:19 +0000)
Mon Aug 23 01:17:59 2004  Matthias Clasen  <maclas@gmx.de>

* gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused
bits in pixel to 1s in case they are used as alpha; copying
code from gdk_colormap_alloc_colors().  (#150466, Rich Wareham)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkrgb.c

index 216d4b624e98f5483f25aeb6ad713b33ff86d331..25cc01c22b5bf8a7a6eaa9ec84d63ec81c7f5274 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Aug 23 01:17:59 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused
+       bits in pixel to 1s in case they are used as alpha; copying
+       code from gdk_colormap_alloc_colors().  (#150466, Rich Wareham)
+
 2004-08-22  Philip Langdale  <plangdale@vmware.com>
 
        * gtk/gtkaction.c (gtk_action_disconnect_proxy): Two signals
index 216d4b624e98f5483f25aeb6ad713b33ff86d331..25cc01c22b5bf8a7a6eaa9ec84d63ec81c7f5274 100644 (file)
@@ -1,3 +1,9 @@
+Mon Aug 23 01:17:59 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused
+       bits in pixel to 1s in case they are used as alpha; copying
+       code from gdk_colormap_alloc_colors().  (#150466, Rich Wareham)
+
 2004-08-22  Philip Langdale  <plangdale@vmware.com>
 
        * gtk/gtkaction.c (gtk_action_disconnect_proxy): Two signals
index 216d4b624e98f5483f25aeb6ad713b33ff86d331..25cc01c22b5bf8a7a6eaa9ec84d63ec81c7f5274 100644 (file)
@@ -1,3 +1,9 @@
+Mon Aug 23 01:17:59 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused
+       bits in pixel to 1s in case they are used as alpha; copying
+       code from gdk_colormap_alloc_colors().  (#150466, Rich Wareham)
+
 2004-08-22  Philip Langdale  <plangdale@vmware.com>
 
        * gtk/gtkaction.c (gtk_action_disconnect_proxy): Two signals
index 216d4b624e98f5483f25aeb6ad713b33ff86d331..25cc01c22b5bf8a7a6eaa9ec84d63ec81c7f5274 100644 (file)
@@ -1,3 +1,9 @@
+Mon Aug 23 01:17:59 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused
+       bits in pixel to 1s in case they are used as alpha; copying
+       code from gdk_colormap_alloc_colors().  (#150466, Rich Wareham)
+
 2004-08-22  Philip Langdale  <plangdale@vmware.com>
 
        * gtk/gtkaction.c (gtk_action_disconnect_proxy): Two signals
index 555cf7d1f5fc173ded89c1577572bec8d8693b60..4dfd315150276ed57326d8411117ef7804e4e4c5 100644 (file)
@@ -745,6 +745,8 @@ gdk_rgb_xpixel_from_rgb_internal (GdkColormap *colormap,
   else if (image_info->visual->type == GDK_VISUAL_TRUE_COLOR ||
           image_info->visual->type == GDK_VISUAL_DIRECT_COLOR)
     {
+      guint32 unused;
+
 #ifdef VERBOSE
       g_print ("shift, prec: r %d %d g %d %d b %d %d\n",
               image_info->visual->red_shift,
@@ -754,8 +756,15 @@ gdk_rgb_xpixel_from_rgb_internal (GdkColormap *colormap,
               image_info->visual->blue_shift,
               image_info->visual->blue_prec);
 #endif
+      /* If bits not used for color are used for something other than padding,
+       * it's likely alpha, so we set them to 1s.
+       */
+      unused = ~ (image_info->visual->red_mask | 
+                 image_info->visual->green_mask | 
+                 image_info->visual->blue_mask |
+                 (((~(guint32)0)) << image_info->visual->depth));
 
-      pixel = (((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) +
+      pixel = (unused + ((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) +
               ((g >> (16 - image_info->visual->green_prec)) << image_info->visual->green_shift) +
               ((b >> (16 - image_info->visual->blue_prec)) << image_info->visual->blue_shift));
     }